import 'package:flutter/material.dart';
import 'package:ninetyfour/l10n/app_localizations.dart';
import '../../manger/global_config.dart';

class PayBottomView extends StatelessWidget {
  final Function(String) onTapLink;
  
  const PayBottomView({super.key, required this.onTapLink});

  @override
  Widget build(BuildContext context) {
    final localizations = AppLocalizations.of(context)!;
    
    return Column(
      children: [
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 15),
          child: Row(
            children: [
              Text(
                localizations.securityAssurance,
                style: TextStyle(
                  color: Color(0xFF333333),
                  fontSize: 14,
                ),
              ),
              Image.asset(
                'assets/images/payicon2.png',
                width: MediaQuery.of(context).size.width / 1.84,
                height: (MediaQuery.of(context).size.width / 1.84) / 8.33,
              ),
            ],
          ),
        ),
        
        Text(
          localizations.clickSubmitOrder,
          style: TextStyle(
            color: Color(0xFF333333),
            fontSize: 12,
          ),
          textAlign: TextAlign.center,
        ),
        
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 10),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              _buildLinkButton(context, localizations.termsOfService, 0),
              _buildLinkButton(context, localizations.refundPolicy, 1),
              _buildLinkButton(context, localizations.privacyAgreement, 2),
            ],
          ),
        ),
      ],
    );
  }
  
  Widget _buildLinkButton(BuildContext context, String text, int index) {
    return GestureDetector(
      onTap: () {
        String url = '';
        if (index == 0) {
          url = UrlConfig.fuwuURL(context);
        } else if (index == 1) {
          url = UrlConfig.tuikuanURL(context);
        } else if (index == 2) {
          url = UrlConfig.privacyPolicyURL(context);
        }
        onTapLink(url);
      },
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 5),
        child: Text(
          text,
          style: TextStyle(
            color: Colors.blue,
            fontSize: 13,
          ),
        ),
      ),
    );
  }
}